package com.totoro.auth;

import com.totoro.auth.bean.AutherProperties;
import com.totoro.auth.service.AuthService;
import org.springframework.boot.autoconfigure.condition.ConditionalOnClass;
import org.springframework.boot.autoconfigure.condition.ConditionalOnMissingBean;
import org.springframework.boot.autoconfigure.condition.ConditionalOnProperty;
import org.springframework.boot.context.properties.EnableConfigurationProperties;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;

import javax.annotation.Resource;

/**
 * Created by Niki on 2018/7/4 11:03
 */
@Configuration
@EnableConfigurationProperties(AutherProperties.class)
@ConditionalOnClass(AuthService.class)
public class AuthAutoConfig {
//    @Resource
//    AutherProperties properties;

    @Bean
    @ConditionalOnMissingBean
    @ConditionalOnProperty(prefix = "auth", value = "enable", havingValue = "true")
    public AuthService authService() {
        AuthService authService = new AuthService();
        return authService;
    }
}
